package cn.wolfcode.rbac.query;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Collections;
import java.util.List;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class PageResult {
	private Integer currentPage=1;
	private Integer pageSize=3;
	private Integer totalCount;
	private List<?> list;
	private Integer totalPage;
	private Integer prevPage;
	private Integer nextPage;
	public PageResult(Integer currentPage,Integer pageSize,Integer totalCount,List<?> result){
		this.currentPage=currentPage;
		this.pageSize=pageSize;
		this.totalCount=totalCount;
		this.list=result;
		totalPage=totalCount%pageSize==0?totalCount/pageSize:totalCount/pageSize+1;
		prevPage=currentPage-1>0?currentPage-1:1;
		nextPage=currentPage+1<=totalPage?currentPage+1:totalPage;
		
	}
	public PageResult(Integer pageSize){
		this(1,pageSize,0,Collections.EMPTY_LIST);
	}
}
